package com.ganbo.pattern.singleton;

/**
 * 恶汉式单利模式
 *
 * @Author: ganbo
 * @Date: 2020/6/8 20:42
 */
public class HungrySingleton {

    private static HungrySingleton instance = new HungrySingleton();

    private HungrySingleton() {
    }

    public static HungrySingleton getInstance() {
        return instance;
    }

    //新增readResolve方法，方式通过序列化和反序列的方式暴力破解
    private Object readResolve(){
        return instance;
    }
}
